import db from '@dfeidao/atom-nodejs/db';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../../atom/config';
interface Message {
	wj_zh: string; wj_zsxm: string; wj_sfz: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:login/zj-000001/s003,action_id:' + action_id);

	log('Service end path:login/zj-000001/s003,action_id:' + action_id);
	const { exec, prepare } = db.query(action_id, session_id, '12');
	const { exec: e, prepare: p } = db.query(action_id, session_id, systemid);
	prepare('pub_user', ['usercode', 'password'], { usercode: message.wj_zh }, 1, 1, [], []);
	const [data] = await exec();
	p('emp_information', ['id_no', 'staff_name'], { staff_name: message.wj_zsxm, id_no: message.wj_sfz }, 1, 1, [], []);
	const [data1] = await e();

	return {
		data: { data1, data }
	};
}
